package com.dream.service2.utils;

public class Kuai {

    public static void quickSort(int[] a,int low,int high) {
        int temp;
        int i = low,j = high;
        if(low < high) {
            temp = a[low];
            while(i != j) {
                while(j>i&&a[j]>=temp) --j;
                if(i<j) {
                    a[i] = a[j];
                    ++i;
                }
                while(i<j&&a[i]<=temp) ++i;
                if(i<j) {
                    a[j] = a[i];
                    --j;
                }
                a[i] = temp;
                quickSort(a, low, i-1);
                quickSort(a, i+1, high);
            }
        }
    }


    public static void main(String[] args) {
        int[] nums = {1,5,4,9,7,8,10,1};
        quickSort(nums, 0, nums.length-1);
        for (int i:nums){
            System.out.print(i);
        }
    }
}
